package com.api.nanc.action;

import com.api.shihua.util.LogTool;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.action.BaseAction;

/*
      检测明细表的子流程是否全部归档

 */
public class CheckSubmitFw extends BaseAction {
    private final static LogTool loghr = new LogTool("/log/hr/",false);
    @Override
    public String execute(RequestInfo requestInfo) {
        String requestid=requestInfo.getRequestid();
        String workflowid=requestInfo.getWorkflowid();
        boolean flag=true;
        loghr.writeLog("CheckSubmit  requestid"+requestid+" "+workflowid);
        RecordSet re=new RecordSet();
        String sql="select a.currentnodetype from  workflow_requestbase a,formtable_main_27 b where  a.requestid=b.requestid and b.mainrequestid='"+requestid+"'";
        re.execute(sql);
        while(re.next()){
             String currentnodetype=Util.null2String(re.getString("currentnodetype")).trim();
             if(!"3".equals(currentnodetype)){
                 flag=false;
             }
        }
        if(!flag){
            requestInfo.getRequestManager().setMessageid("10001");
            requestInfo.getRequestManager().setMessagecontent("存在未回复的意见不能提交归档!");
            return Action.FAILURE_AND_CONTINUE;
        }
        return super.execute(requestInfo);
    }
}
